package cn.shoukaiseki.sjf4j.fastjson;

import cn.shoukaiseki.sjf4j.node.JsonNodeType;

import java.math.BigDecimal;

public abstract class FastjsonNumericNode<T extends Number> extends FastjsonValueNode<T>{

    public FastjsonNumericNode(T value) {
        super(value);
    }

    @Override
    public JsonNodeType getNodeType() {
        return JsonNodeType.NUMBER;
    }

    @Override
    public Long asLongVal() {
        if(value==null){return null;}
        return value.longValue();
    }

    @Override
    public int asInt() {
        return value.intValue();
    }

    @Override
    public Integer asIntVal() {
        if(value==null){return null;}
        return value.intValue();
    }

    @Override
    public long asLong() {
        return value.longValue();
    }

    @Override
    public double asDouble() {
        return value.doubleValue();
    }

    @Override
    public Double asDoubleVal() {
        if(value==null){return null;}
        return value.doubleValue();
    }

}
